#!/bin/sh
# This script finishes a chroot after stage0 or stage1 is built into it

if [ ! "$H" -o ! "$R" -o ! "$K" ] ; then
	echo "some required env variables not set. run . ./config before executing this"
	exit 1
fi

cp -r "$H"/KEEP "$H"/pkg "$H"/utils "$R"/src/     
cp "$H"/COOKBOOK "$H"/LICENSE "$H"/README.md "$H"/THANKS "$R"/src/
cp "$H"/build-stage "$H"/enter-chroot "$R"/src/ 

cp "$K"/config.stage1 "$R"/src/config
echo "export A=$A" >> "$R"/src/config
[ -z "$MAKE_THREADS" ] || sed -i "s@MAKE_THREADS=1@MAKE_THREADS=$MAKE_THREADS@" "$R"/src/config

ln -s /proc/mounts "$R"/etc/mtab

